/*
 * KKCanvas.h
 *
 *  Created on: 2013-9-23
 *      Author: wanghua
 */

#ifndef KKCANVAS_H_
#define KKCANVAS_H_


#include "kaka_common.h"
#include "KKLayer.h"
#include "KKRibbon.h"

using namespace std;

USING_NS_CC;

typedef KKMutableArray<KKRibbon*> KKStrokeArray;

class KKCanvas: public KKLayer {
private:
	;CC_SYNTHESIZE(KKStrokeArray*,m_strokes,Strokes)
	;CC_SYNTHESIZE(KKRibbon*,m_currentStroke,CurrentStroke)
	;CC_SYNTHESIZE(const char*,m_pen,Pen)
	;CC_SYNTHESIZE(ccColor4B, m_strokeColor, StrokeColor)
	;CC_SYNTHESIZE(int,m_strokeWidth,StrokeWidth)
	;CC_SYNTHESIZE(vector<CCPoint>,m_strokePoints,StrokePoints)
	;
public:
	KKCanvas();

	virtual ~KKCanvas();

	KKNODE_FACTORY_METHOD(KKCanvas,canvasWithXml)
	;

	virtual bool initCommonInfoWithXml(TiXmlElement* element, KKNode* parent);

	static KKCanvas * canvasWithTarget(KKNode* target, const char* brushfile);

	void newStroke(CCPoint start);

	void easeStroke();

	void addPoint(CCPoint end);

	void clear();

	bool saveImage(const char *szFilePath,bool allCanvas=false);

	virtual void onScroll(const KKTouch& touch, const CCPoint& dir);
	virtual void onDown(const KKTouch& touch);
	virtual void onUp(const KKTouch& touch);

};

KKNODE_PARSER_CLASS(KKCanvasParser,KKCanvas,canvasWithXml)
;

#endif /* KKCANVAS_H_ */
